<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Model;
use Illuminate\Support\Arr;

class Order extends Model
{
    protected $table = 'order';
    protected $guarded = ['id'];

    protected $appends = ['status_name'];

    public function getStatusNameAttribute()
    {
        return Arr::get(config('freeswitch.order_status'),$this->status,'');
    }

    public function customer()
    {
        return $this->hasOne(Customer::class,'id','customer_id');
    }

    public function cost()
    {
        return $this->belongsToMany(Channel::class,'order_channel','order_id','channel_id')->withPivot(['channel_company','money']);
    }

}
